<?xml version="1.0"?>
<!DOCTYPE xsl:stylesheet [
  <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#">
  <!ENTITY dc "http://purl.org/dc/elements/1.1/">
  <!ENTITY dcterms "http://purl.org/dc/terms/">
  <!ENTITY foaf "http://xmlns.com/foaf/0.1/">
  <!ENTITY a "http://xmlns.heustics.org/schema/myelin/0.1/">
  <!ENTITY m "http://xmlns.heustics.org/ontology/myelin/0.1/">
]>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  xmlns:str="http://exslt.org/strings"
  xmlns:l="http://xmlns.heustics.org/schema/i18n/0.1/"
  xmlns:a="&a;"
  xmlns:o="&a;AgentAccount#"
  exclude-result-prefixes="xsl a l o str"
>    
  <xsl:variable name="o:l10n" select="a:get-l10n('&a;AgentAccount')"/>  
  <xsl:variable name="o:params-l10n" select="$o:l10n/l:context[@name='params']/*"/>
  <xsl:variable name="o:hints-l10n" select="$o:l10n/l:context[@name='param-hints']/*"/>
  
  <xsl:template match="a:agent" mode="a:input-hidden">
    <xsl:apply-templates mode="a:input-hidden"/>
  </xsl:template>
  
  <xsl:template match="a:agent" mode="a:input-show">
    <xsl:apply-templates mode="a:input-show"/>
  </xsl:template>   
  
  <xsl:template match="a:nick" mode="a:input-show" name="o:nick-input"> 
    <xsl:param name="params-l10n" select="$o:params-l10n"/>
    <xsl:param name="hints-l10n" select="$o:hints-l10n"/>
    <xsl:param name="read-only" select="@system-nick"/>
    <div class='input text nick'>  
      <div class="key">        
        <div>
          <xsl:call-template name="a:label-class-attr"/>
          <span><xsl:value-of select="$params-l10n[@key='nick']"/></span>
          <div class="spacer"/>
        </div>   
        <div class='hint'>
          <xsl:call-template name="a:input-hints">
            <xsl:with-param name="hint" select="$o:hints-l10n[@key='nick']"/>
          </xsl:call-template>
          <div class="spacer"/>
        </div>     
        <div class="spacer"/>
      </div>      
      <div class='value'>    
        <xsl:choose>
          <xsl:when test="$read-only">
            <span><xsl:value-of select="."/></span>
          </xsl:when>
          <xsl:otherwise>
            <input class='large' type="text" value="{.}" name="nick"/>  
          </xsl:otherwise>
        </xsl:choose>                    
        <div class="spacer"/>
      </div>
      <div class='spacer'/>
    </div>
  </xsl:template>
  
  <xsl:template match="a:name" mode="a:input-show" name="o:name-input">
    <xsl:param name="params-l10n" select="$o:params-l10n"/>
    <xsl:param name="hints-l10n" select="$o:hints-l10n"/>
    <xsl:param name="read-only" select="@read-only"/>        
    <div class='input text name'>      
      <div class="key">
        <div>
          <xsl:call-template name="a:label-class-attr"/>
          <span><xsl:value-of select="$params-l10n[@key='name']"/></span>
          <div class="spacer"/>
        </div>        
        <div class='hint'>
          <xsl:call-template name="a:input-hints">
            <xsl:with-param name="hint" select="$o:hints-l10n[@key='name']"/>
          </xsl:call-template>
          <div class="spacer"/>
        </div>
        <div class="spacer"/>
      </div>      
      <div class='value'>
        <xsl:choose>
          <xsl:when test="$read-only">
            <span><xsl:value-of select="."/></span>
          </xsl:when>
          <xsl:otherwise>
            <input class='large' type="text" value="{.}" name="name"/>  
          </xsl:otherwise>
        </xsl:choose>      
        <div class="spacer"/>
      </div>
      <div class='spacer'/>
    </div>
  </xsl:template>
  
  <xsl:template match="a:mbox" mode="a:input-show" name="o:mbox-input">
    <xsl:param name="params-l10n" select="$o:params-l10n"/>
    <xsl:param name="hints-l10n" select="$o:hints-l10n"/> 
    <xsl:param name="read-only"/>     
    <div class='input text mbox'>  
      <div class="key">
        <div>
          <xsl:call-template name="a:label-class-attr"/>
          <span><xsl:value-of select="$params-l10n[@key='mbox']"/></span>
          <div class="spacer"/>
        </div>        
        <div class='hint'>
          <xsl:call-template name="a:input-hints">
            <xsl:with-param name="hint" select="$o:hints-l10n[@key='mbox']"/>
          </xsl:call-template>
          <div class="spacer"/>
        </div>
        <div class="spacer"/>
      </div>      
      <div class='value'>
        <xsl:choose>
          <xsl:when test="$read-only">
            <span><xsl:value-of select="substring(@uri,8)"/></span>
          </xsl:when>
          <xsl:otherwise>
            <xsl:choose>
              <xsl:when test="substring(@uri,1,7)='mailto:'">
                <input class='large' type="text" value="{substring(@uri,8)}" name="mbox"/>
              </xsl:when>
              <xsl:otherwise>
                <input class='large' type="text" value="{@uri}" name="mbox"/>
              </xsl:otherwise>
            </xsl:choose>
          </xsl:otherwise>
        </xsl:choose>                      
        <div class="spacer"/>
      </div>
      <div class='spacer'/>
    </div>
  </xsl:template>
  
  <xsl:template match="a:homepage" mode="a:input-show" name="o:homepage-input"> 
    <div class='input text homepage'>  
      <div class="key">
        <div>
          <xsl:call-template name="a:label-class-attr"/>
          <span><xsl:value-of select="$o:params-l10n[@key='homepage']"/></span>
          <div class="spacer"/>
        </div>        
        <div class='hint'>
          <xsl:call-template name="a:input-hints">
            <xsl:with-param name="hint" select="$o:hints-l10n[@key='homepage']"/>
          </xsl:call-template>
          <div class="spacer"/>
        </div>
        <div class="spacer"/>
      </div>      
      <div class='value'>
        <xsl:choose>
          <xsl:when test="substring(@uri,1,7)='http://'">
            <input class='large' type="text" value="{substring(@uri,8)}" name="homepage"/>
          </xsl:when>
          <xsl:otherwise>
            <input class='large' type="text" value="{@uri}" name="homepage"/>
          </xsl:otherwise>
        </xsl:choose>    
        <div class="spacer"/>
      </div>
      <div class='spacer'/>
    </div>
  </xsl:template> 
  
  <xsl:template match="a:memberships" mode="a:input-show">
    <xsl:apply-templates mode="a:input-show"/>
  </xsl:template> 
  
  <xsl:template match="a:group" mode="a:input-show"/>
  
  <xsl:template match="a:domain" mode="a:input-show">     
    <xsl:variable name="opts" select="a:options"/>
    <xsl:if test="$opts/@count &gt; 1">
    <div class='input text domain'>  
      <div class="key">        
        <div>
          <xsl:call-template name="a:label-class-attr"/>
          <span><xsl:value-of select="$o:params-l10n[@key='domain']"/></span>
          <div class="spacer"/>
        </div>  
        <div class='hint'>
          <xsl:call-template name="a:input-hints">
            <xsl:with-param name="hint" select="$o:hints-l10n[@key='domain']"/>
          </xsl:call-template>
          <div class="spacer"/>
        </div>
        <div class="spacer"/>
      </div>      
      <div class='value'>    
        <div class="entry">          
          <xsl:choose>
            <xsl:when test="$opts/@count &gt; 1">
              <select name="domain">          
                <xsl:apply-templates select="$opts/*" mode="a:single-select-label">
                  <xsl:with-param name="selected" select="@selected"/>     
                </xsl:apply-templates>
              </select>    
            </xsl:when>
            <xsl:when test="$opts/@count = 1 and $opts/*[1]/@label">
              <span>
                <xsl:value-of select="$opts/*[1]/@label"/>
              </span>
            </xsl:when>
            <xsl:otherwise>
              <span>
                <xsl:value-of select="$o:params-l10n[@key='no-domains']"/>
              </span>
            </xsl:otherwise>
          </xsl:choose>
          <div class="spacer"/>
        </div>
        <div class="spacer"/>
      </div>
      <div class='spacer'/>
    </div>
    </xsl:if>
  </xsl:template>
 
</xsl:stylesheet>